﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
using Yoozoo.UI.YGUI;

[RequireComponent(typeof(YRawImage))]
public class YCaptureContainer : YPrefabContainer
{
    public Vector2 renderTexutreSize=new Vector2(256,256);
    
    public Camera camera;
    public YRawImage rawImage;

    private RenderTexture m_renderTexture;
    // Start is called before the first frame update
    void Start()
    {
        camera = GetComponentInChildren<Camera>();
        m_renderTexture=new RenderTexture((int)renderTexutreSize.x,(int)renderTexutreSize.y,16,RenderTextureFormat.BGRA32);
        rawImage.texture = m_renderTexture;
        camera.targetTexture = m_renderTexture;
    }
    protected override void OnDestroy()
    {
        if (m_renderTexture!=null)
        {
            UnityEngine.Object.Destroy(m_renderTexture);
        }
        base.OnDestroy();
    }

    protected override void OnLoadedPrefab()
    {
        base.OnLoadedPrefab();
        
    }
}
